package com.bwie.controller;

import com.bwie.pojo.Prod;
import com.bwie.service.ProdService;
import com.bwie.service.impl.ProdServiceImpl;
import com.bwie.utils.R;
import com.bwie.vo.PageInfoVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.License;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import org.springframework.beans.factory.annotation.Autowired;

import java.util.List;

/**
 * 商品表(tb_prod)表控制层
 *
 * @author xxxxx
 */
@RestController
@RequestMapping("/product/product")
@Api(tags = "商品管理")
public class ProdController {
    /**
     * 服务对象
     */
    @Autowired
    private ProdService prodService;

    /**
     * @author: 鑫仔
     * @description: 商品列表
     * @params: [com.bwie.vo.PageInfoVo]
     * @return: com.bwie.utils.R
     * @date: 2025/7/22 9:54
     */
    @ApiOperation("商品列表")
    @PostMapping("getProdList")
    public R getProdList(
            @RequestBody PageInfoVo pageInfoVo
    ) {
        return prodService.getProdList(pageInfoVo);
    }

    /**
     * @author: 鑫仔
     * @description: 商品详情
     * @params: [java.lang.Integer]
     * @return: com.bwie.utils.R
     * @date: 2025/7/25 19:45
     */
    @PostMapping("getProd/{prodId}")
    public R getProd(@PathVariable(name = "prodId") Integer prodId) {
        return prodService.prodInfo(prodId);
    }

    /**
     * @author: 鑫仔
     * @description: 批量删除商品
     * @params: []
     * @return: com.bwie.utils.R
     * @date: 2025/7/22 10:56
     */
    @ApiOperation("批量删除商品")
    @PostMapping("deleteBatchProd")
    public R deleteBatchProd(
            @RequestBody List<Integer> ids
    ) {
        return prodService.deleteBatchProd(ids);
    }


    /**
     * @author: 鑫仔
     * @description: 新增商品
     * @params: []
     * @return: com.bwie.utils.R
     * @date: 2025/7/22 11:37
     */
    @ApiOperation("新增商品")
    @PostMapping("addProd")
    public R addProd(
            @RequestBody @Validated Prod prod
    ) {
        return prodService.addProd(prod);
    }

}
